﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="IStorageService.cs" company="XamlNinja">
//   2011 Richard Griffin and Ollie Riches
// </copyright>
// <summary>
//   Interface defining the storage service API.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace WP7Contrib.Services.Storage
{
    using System.Linq.Expressions;

    /// <summary>
    /// Interface defining the storage service API.
    /// </summary>
    public interface IStorageService
    {
        /// <summary>
        /// Opens an instance of the transient storage, the contents will not survive an application restart.
        /// </summary>
        /// <param name="name">
        /// The context for the storage, e.g. view model name
        /// </param>
        /// <returns>
        /// Returns an instance of the transient storage.
        /// </returns>
        IStorage OpenTransient(string name);

        /// <summary>
        /// Opens an instance of the transient storage, the contents will not survive an application restart.
        /// </summary>
        /// <param name="expression">
        /// An expression used to express the name of the context for the storage, e.g. '() =&gt; MyPropertyName'
        /// </param>
        /// <typeparam name="T">
        /// The type contained in the expression.
        /// </typeparam>
        /// <returns>
        /// Returns an instance of the transient storage.
        /// </returns>
        IStorage OpenTransient<T>(Expression<System.Func<T>> expression);

        /// <summary>
        /// Opens an instance of the persistent storage, the contents will not survive an application restart.
        /// </summary>
        /// <param name="name">
        /// The context for the storage, e.g. view model name
        /// </param>
        /// <returns>
        /// Returns an instance of the persistent storage.
        /// </returns>
        IStorage OpenPersistent(string name);

        /// <summary>
        /// Opens an instance of the persistent storage, the contents will not survive an application restart.
        /// </summary>
        /// <param name="expression">
        /// An expression used to express the name of the context for the storage, e.g. '() =&gt; MyPropertyName'
        /// </param>
        /// <typeparam name="T">
        /// The type contained in the expression.
        /// </typeparam>
        /// <returns>
        /// Returns an instance of the persistent storage.
        /// </returns>
        IStorage OpenPersistent<T>(Expression<System.Func<T>> expression);
    }
}